斐波那契数列 Posted on 2019-09-10 | In 剑指offer | | reads times 斐波那契数列题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。 1234567891011function Fibonacci(n){ // write code here var curr=0; var last=1; while(n--){ curr+=last; last=curr-last; } return curr;} Post author: GoldMiner Xun Post link: https://goldminerxun.github.io/2019/09/10/%E5%89%91%E6%8C%87offer%20JavaScript%E7%89%88%20(7)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.